/**
 * lilang
 * PofBulletinAction.java
 * 2013-10-13下午6:56:34
 */
package com.cq.oa.web.pof.action;

import oa.base.util.Constants;
import oa.base.util.Page;
import oa.base.web.Action.BaseAction;

import com.cq.oa.domain.dto.BulletinDto;
import com.cq.oa.domain.pof.Bulletin;
import com.cq.oa.service.pof.BulletinService;


/**
 * @author lilang
 *
 */
@SuppressWarnings("serial")
public class PofBulletinAction extends BaseAction<Bulletin>{

	/* (non-Javadoc)
	 * @see oa.base.web.Action.BaseAction#getEntityClass()
	 */
	@Override
	protected Class<Bulletin> getEntityClass() {
		return Bulletin.class;
	}
	
	private String objectIds;
	
	private String cnames;
	
	private Integer types;
	
	private String fileIds;
	
	private BulletinDto dto;
	
	
	
	
	public BulletinDto getDto() {
		return dto;
	}

	public void setDto(BulletinDto dto) {
		this.dto = dto;
	}

	public String getObjectIds() {
		return objectIds;
	}

	public void setObjectIds(String objectIds) {
		this.objectIds = objectIds;
	}

	public String getCnames() {
		return cnames;
	}

	public void setCnames(String cnames) {
		this.cnames = cnames;
	}

	public Integer getTypes() {
		return types;
	}

	public void setTypes(Integer types) {
		this.types = types;
	}

	public String getFileIds() {
		return fileIds;
	}

	public void setFileIds(String fileIds) {
		this.fileIds = fileIds;
	}

	public BulletinService bulletinService;

	public void setBulletinService(BulletinService bulletinService) {
		this.bulletinService = bulletinService;
	}
	
	public String operate(){
		if(null!=entity.getSid()){
			dto = bulletinService.findByBulletin(entity.getSid());
		}
		return "operate";
	}
	
	public String save(){
		if(null!=entity.getSid()){
			this.bulletinService.updateNews(dto);
		}else{
			this.bulletinService.doInsertNews(dto);
		}
		this.renderJsonSuccess();
		return JSON;
	}
	
	
	public String findPage() throws Exception{
		filterMap.put(Constants.WHERE_LIKE+"title", entity.getTitle());
		Page<Bulletin> page = this.bulletinService.findPageByParams(filterMap, super.getPageNo(), super.getPageSize());
		this.renderJsonSuccess(jsonUtils.getExtJson(page, new String[] {}));
		return JSON;
	}
	
	public String findByPage() throws Exception{
		filterMap.put(Constants.WHERE_LIKE+"title", entity.getTitle());
		Page<Bulletin> page = this.bulletinService.findByPage(filterMap, linkMap, shortMap,super.getPageNo(), super.getPageSize());
		this.renderJsonSuccess(jsonUtils.getExtJson(page, new String[] {}));
		return JSON;
	}
	
	
	public String delete(){
		this.bulletinService.delete(entity.getSid());
		this.renderJsonSuccess();
		return JSON;
	}
	
	public String detail(){
		dto = bulletinService.doViewBulletin(entity.getSid());
		return "detail";
	}

}
